package exceptionExample;
import java.io.IOException;

class MyExcep extends Exception{
    public MyExcep()
    {
        System.out.println("你输入非大写字母！");
    }
}
public class MyException {
    public static void inputChar()
    {
        try
        {
            char c;
            while(true)
            {
                c = (char)System.in.read();
                if(c>='A' && c<='Z')
                {
                    System.out.println(c);
                }
                else if(c == '\n')
                {
                    break;
                }
                else
                {
                    throw new MyExcep();
                }
            }
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
        catch(Exception e)
        {}
    }
    public static void main(String[] args) {
        MyException.inputChar();
    }
}
